﻿Imports System.Data.OleDb

Public Class AddChineseFood
    Inherits System.Web.UI.Page

    Protected Sub PressMe_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_PressMe.Click

        If (fu_Picture.HasFile) = True Then
            fu_Picture.SaveAs(Request.MapPath("Pictures") & "/" & fu_Picture.FileName)
        End If

        Dim conn = New OleDbConnection(ConfigurationManager.ConnectionStrings("ChineseFoodConn").ConnectionString)
        Dim sql = New String("INSERT INTO ClassicChineseFood (ChineseFoodName_English, ChineseFoodName_Chinese, AreaOfOrigin_English, AreaOfOrigin_Chinese,  Hot, Vegetarian, Picture, AreaOfOriginUrl_English_GoogleMap, ChineseFoodUrl_English_Wikipedia, ChineseFoodUrl_Chinese_Baidu) VALUES (@f1, @f2, @f3, @f4, @f5, @f6, @f7, @f8, @f9, @f10)")
        Dim cmd = New OleDbCommand(sql, conn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tb_ChineseFoodNameEnglish.Text)
        cmd.Parameters.AddWithValue("@f2", tb_ChineseFoodNameChinese.Text)
        cmd.Parameters.AddWithValue("@f3", tb_AreaOfOriginEnglish.Text)
        cmd.Parameters.AddWithValue("@f4", tb_AreaOfOriginChinese.Text)
        'cmd.Parameters.AddWithValue("@f5", ddl_Rating.SelectedValue)
        'deleted the above one, because I deleted field rating in table ClassicChineseFood, to see the reason why I deleted rating, please see log on codeplex final website V11 and V12
        cmd.Parameters.AddWithValue("@f5", ddl_Hot.SelectedValue)
        cmd.Parameters.AddWithValue("@f6", ddl_Vegetarian.SelectedValue)
        cmd.Parameters.AddWithValue("@f7", "Pictures/" & fu_Picture.FileName)
        cmd.Parameters.AddWithValue("@f8", tb_AreaOfOriginUrlEnglish.Text)
        cmd.Parameters.AddWithValue("@f9", tb_ChineseFoodUrlEnglish.Text)
        cmd.Parameters.AddWithValue("@f10", tb_ChineseFoodUrlChinese.Text)
        conn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("Confirmation.aspx")
        conn.Close()
    End Sub
End Class